package com.ruoyi.web.controller.modules;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.modules.domain.TransportationCompanyCertificate;
import com.ruoyi.modules.service.ITransportationCompanyCertificateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 运输许可证申报Controller
 * 
 * @author ssh
 * @date 2024-12-15
 */
@RestController
@RequestMapping("/modules/tranCompany/certificate")
public class TransportationCompanyCertificateController extends BaseController
{
    @Autowired
    private ITransportationCompanyCertificateService transportationCompanyCertificateService;

    /**
     * 查询运输许可证申报列表
     */
    @PreAuthorize("@ss.hasPermi('modules:tranCompany:certificate:list')")
    @GetMapping("/list")
    public TableDataInfo list(TransportationCompanyCertificate transportationCompanyCertificate)
    {
        startPage();
        List<TransportationCompanyCertificate> list = transportationCompanyCertificateService.selectTransportationCompanyCertificateList(transportationCompanyCertificate);
        return getDataTable(list);
    }

    /**
     * 导出运输许可证申报列表
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:export')")
    @Log(title = "运输许可证申报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TransportationCompanyCertificate transportationCompanyCertificate)
    {
        List<TransportationCompanyCertificate> list = transportationCompanyCertificateService.selectTransportationCompanyCertificateList(transportationCompanyCertificate);
        ExcelUtil<TransportationCompanyCertificate> util = new ExcelUtil<TransportationCompanyCertificate>(TransportationCompanyCertificate.class);
        util.exportExcel(response, list, "运输许可证申报数据");
    }

    /**
     * 获取运输许可证申报详细信息
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(transportationCompanyCertificateService.selectTransportationCompanyCertificateById(id));
    }

    /**
     * 新增运输许可证申报
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:add')")
    @Log(title = "运输许可证申报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TransportationCompanyCertificate transportationCompanyCertificate)
    {
        return toAjax(transportationCompanyCertificateService.insertTransportationCompanyCertificate(transportationCompanyCertificate));
    }

    /**
     * 修改运输许可证申报
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:edit')")
    @Log(title = "运输许可证申报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TransportationCompanyCertificate transportationCompanyCertificate)
    {
        return toAjax(transportationCompanyCertificateService.updateTransportationCompanyCertificate(transportationCompanyCertificate));
    }

    /**
     * 删除运输许可证申报
     */
    @PreAuthorize("@ss.hasPermi('modules:certificate:remove')")
    @Log(title = "运输许可证申报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(transportationCompanyCertificateService.deleteTransportationCompanyCertificateByIds(ids));
    }
}
